package test

import (
	"context"
	"fmt"

	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
)

func Del(mongo *mongo.Database, ctx context.Context) {
	// 删除一条
	findFilter := bson.M{"id": 3}
	result, _ := mongo.Collection("test").DeleteOne(ctx, findFilter)
	fmt.Println(result.DeletedCount)

	// 删除多条记录
	findFilter2 := bson.M{"add1list.text": "hello3"}
	result, _ = mongo.Collection("test").DeleteMany(ctx, findFilter2)
	fmt.Println(result.DeletedCount)

	// 删除全部
	result, _ = mongo.Collection("test").DeleteMany(ctx, bson.M{})
	fmt.Println(result.DeletedCount)

}
